import axios from "axios";
// 配置访问路径
// 艾铂地址
axios.defaults.baseURL = "https://iotcloud.sc-iot.cn:22002/";
// 艾欧特地址
// axios.defaults.baseURL = "https://iotcloud.sc-iot.cn:22001/";

// axios.defaults.baseURL = "http://iot8:9003/";

axios.defaults.headers["Content-Type"] = "application/x-www-form-urlencoded;charset=UTF-8";
// 请求拦截
axios.interceptors.request.use(config => {
  let authorization = "Bearer " + sessionStorage.getItem('token');
  config.headers = { ...config.headers, Authorization: "Bearer " + sessionStorage.getItem('token') }
  if (authorization === 'Bearer null') {
    config.headers['Authorization'] = authorization
  }
  return config
}, error => {
  Promise.reject(error)
})
export default axios